﻿<UserControl x:Class="DemoNYTimes.CongressionalBillPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    d:DesignWidth="640" d:DesignHeight="480" xmlns:nyt="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" 
    xmlns:nytvc="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" FontFamily="Times New Roman">
	<UserControl.Resources>
		<nytvc:BillToDetailsConverter x:Key="BillToDetailsConverter"/>
		<nyt:RecentBills x:Key="RecentBillsDS" d:IsDataSource="True" CongressNumber="111"  />
        <nytvc:ChamberConverter x:Key="ChamberConverter"/>
        <nytvc:BillConverter x:Key="BillConverter"/>
        <nyt:CongressBill x:Key="CongressBillDS" d:IsDataSource="True" CongressNumber="111"/>
        <DataTemplate x:Key="BillTemplate">
        	<Grid ToolTipService.ToolTip="{Binding Title}">
        		<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="{Binding Id}" TextWrapping="Wrap"/>
        	</Grid>
        </DataTemplate>
        <Style x:Key="SectionBorder" TargetType="Border">
        	<Setter Property="Background" Value="#FFBFBFBF"/>
        	<Setter Property="CornerRadius" Value="5,5,5,5"/>
        	<Setter Property="Margin" Value="4,4,8,4"/>
        </Style>
        <Style x:Key="Subtitle" TargetType="TextBlock">
        	<Setter Property="FontSize" Value="16"/>
        	<Setter Property="Margin" Value="4,4,4,0"/>
        </Style>
	</UserControl.Resources>
	<Grid x:Name="LayoutRoot" Background="White">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
			<RowDefinition/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<StackPanel HorizontalAlignment="Left" Margin="4,4,4,0" Width="Auto" VerticalAlignment="Bottom">
			<TextBlock Text="Chamber:" TextWrapping="Wrap"/>
			<RadioButton Content="House" GroupName="Chamber" IsChecked="{Binding Mode=TwoWay, Path=Chamber, Source={StaticResource RecentBillsDS}, Converter={StaticResource ChamberConverter}, ConverterParameter=House}"/>
			<RadioButton Content="Senate" GroupName="Chamber" IsChecked="{Binding Mode=TwoWay, Path=Chamber, Source={StaticResource RecentBillsDS}, Converter={StaticResource ChamberConverter}, ConverterParameter=Senate}" />
			<TextBlock Text="Recent Bills:" TextWrapping="Wrap"/>
		</StackPanel>
		<ListBox ItemsSource="{Binding Mode=OneWay, Path=Bills, Source={StaticResource RecentBillsDS}}" 
		Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled" SelectedItem="{Binding Mode=TwoWay, Path=BillId, Source={StaticResource CongressBillDS}, Converter={StaticResource BillConverter}}" Grid.RowSpan="3" x:Name="RecentBills" Margin="4,4,4,4" ItemTemplate="{StaticResource BillTemplate}"/>
		<Border Grid.ColumnSpan="1" Grid.Row="1" Grid.Column="1" Style="{StaticResource SectionBorder}">
			<StackPanel Height="Auto" Width="Auto">
				<TextBlock Text="Subjects" TextWrapping="Wrap" Margin="2,2,2,0" Style="{StaticResource Subtitle}"/>
				<ListBox Width="Auto" x:Name="Subjects" 
                    ItemsSource="{Binding SelectedItem, Converter={StaticResource BillToDetailsConverter}, ElementName=RecentBills, Mode=OneWay, ConverterParameter=subjects}" 
                         Height="Auto" Background="{x:Null}" Margin="2,2,2,2"/>
			</StackPanel>
		</Border>
		<Border Height="Auto" VerticalAlignment="Stretch" Grid.ColumnSpan="1" Grid.Row="2" Grid.Column="1" Style="{StaticResource SectionBorder}">
			<StackPanel Height="Auto" Width="Auto">
				<TextBlock Text="Amendments" TextWrapping="Wrap" Style="{StaticResource Subtitle}"/>
				<ListBox Width="Auto" x:Name="Amendments" 
                         ItemsSource="{Binding SelectedItem, Converter={StaticResource BillToDetailsConverter}, ElementName=RecentBills, Mode=OneWay, ConverterParameter=amendments}" 
                         Height="Auto" Background="{x:Null}"/>
			</StackPanel>
		</Border>
		<Border Grid.ColumnSpan="1" Grid.Row="3" Grid.RowSpan="1" Grid.Column="1" Style="{StaticResource SectionBorder}">
			<StackPanel Height="Auto" Width="Auto">
				<TextBlock Text="Related Bills" TextWrapping="Wrap" Style="{StaticResource Subtitle}"/>
				<ListBox Width="Auto" ItemsSource="{Binding SelectedItem, Converter={StaticResource BillToDetailsConverter}, ElementName=RecentBills, Mode=OneWay, ConverterParameter=related}"  Height="Auto" x:Name="RelatedBills"/>
			</StackPanel>
		</Border>
		<StackPanel Grid.Column="1" Margin="4,8,8,4">
			<TextBlock Text="{Binding Mode=OneWay, Path=Bill.Title, Source={StaticResource CongressBillDS}}" TextWrapping="Wrap" FontFamily="Times New Roman" FontSize="16"/>
			<TextBlock Text="{Binding Mode=OneWay, Path=Bill.LatestMajorActionDate, Source={StaticResource CongressBillDS}}" TextWrapping="Wrap"/>
			<TextBlock Text="{Binding Mode=OneWay, Path=Bill.LatestMajorAction, Source={StaticResource CongressBillDS}}" TextWrapping="Wrap"/>
			<TextBlock Text="{Binding Mode=OneWay, Path=Bill.Sponsor, Source={StaticResource CongressBillDS}}" TextWrapping="Wrap"/>
		</StackPanel>
	</Grid>
</UserControl>
